package com.wangjie.define.compare;

public class Dog implements Comparable{
    private int age;

    public Dog(int age) {
        this.age = age;
    }

    @Override
    public int compare(Object o) {
        Dog dog = (Dog) o;
        if(this.age > dog.age) return 1;
        else if (this.age < dog.age) return -1;
        else return 0;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "age=" + age +
                '}';
    }
}
